import { optimize } from 'webpack'
import { PATH_REACT_PLAYER, PATH_DIST,PATH_ROOT, PATH_SRC, PLUGINS_PATH, CopyWebpackConf, getCopyPlugins } from './config.babel'
import config from './production.babel'
import path from 'path'
import CopyWebpackPlugin from 'copy-webpack-plugin'

export default {
  ...config,
  entry: PATH_REACT_PLAYER,
  output: {
    path: PATH_DIST,
    filename: 'ReactPlayer.js',
    library: 'ReactPlayer',
    libraryExport: 'default'
  },
  externals: {
    react: 'React'
  },
  resolve: {
    extensions: [".ts", ".tsx", ".js"],
  },
  module: {
    rules: [
      {
        test: /\.js$/,
      exclude: [ /node_modules/, PLUGINS_PATH ],
        loader: 'babel-loader'
      },
      {
        test: /\.ts$/,
      exclude: [ /node_modules/, PLUGINS_PATH ],
        use: [
          {
            loader: 'babel-loader'
          },
          {
            loader: 'ts-loader',
            options: {
              transpileOnly: true, // 只进行转译，不进行类型检查
            }
          }
        ],
        exclude: /node_modules/,
      }
    ]
  },
  plugins: [
    new optimize.LimitChunkCountPlugin({
      maxChunks: 1
    }),
    getCopyPlugins(PATH_DIST)
  ]
}
